window.onload = function(){
    axios.get("/checkLogin")
        .then(function (response) {
            var data = response.data;
            if(data.isLogin){
                window.location="my.html";
            }
        })
    let inputText = document.getElementsByClassName("text");
    for(var i=0 ; i<inputText.length ; i++){
        let subtitle = inputText[i].nextSibling.nextSibling.nextSibling.nextSibling
        inputText[i].onfocus=function() {
            subtitle.style.bottom="10vw";
            subtitle.style.fontSize="5.87vw";
            subtitle.style.color="#636e72"
        }
        inputText[i].onblur=function() {
            if(this.value===""){
                subtitle.style.bottom="1.33vw";
                subtitle.style.fontSize="8vw";
                subtitle.style.color="#000"
            }
        }
    }
    let loginBtn = document.getElementById("login-btn");
    var msg =new Vue({
        el:'#msg',
        data:{
            msg:"登录成功了但也不一定"
        }
    });
    loginBtn.onclick =function (){
        let username=document.getElementById("username").value;
        let password=document.getElementById("password").value;
        let msgBox = document.getElementById("msg");
        if(username==="" || password===""){
            msgBox.className="msg";
            msg.msg="账号和密码不能为空！";
            console.log(msg.msg);
        }else {
            axios.get("/login?username="+username+"&password="+password)
                .then(function (response) {
                    let data = response.data;
                    msgBox.className="msg";
                    msg.msg = data.msg;
                    if(data.state){
                        window.location="my.html";
                    }
                })
        }
    }
}